import scrapy


class BaiduSpider(scrapy.Spider):
    name = "baidu"
    allowed_domains = ["baidu.com"]
    start_urls = ["https://www.baidu.com"]

    def parse(self, response):
        #方式一 ：xpath
        title = response.xpath('//title/text()').getall()
        print(title)
        title = response.xpath('//title/text()').get()
        print(title)
        title = response.xpath('//title/text()').extract()
        print(title)
        title = response.xpath('//title/text()').extract_first()
        print(title)
        #方式二 ：css
        print('='*10)
        title = response.css('title::text').get()
        print(title)
        title = response.css('title').xpath('./text()').get()
        print(title)
